﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.IO;
using System.Data;
using System.Reflection;
using System.Xml.Linq;
namespace VPIC_EDILib
{
    public class Config
    {
        private string _ServerName;
        public string ServerName
        {
            get { return _ServerName; }
            set { _ServerName = value; }
        }
        private string _DBName;
        public string DBName
        {
            get { return _DBName; }
            set { _DBName = value; }
        }
        private string _ShareFoldeCSV;
        public string ShareFolderCSV
        {
            get { return _ShareFoldeCSV; }
            set { _ShareFoldeCSV = value; }
        }
        private string _ShareFolderXML;
        public string ShareFolderXML
        {
            get { return _ShareFolderXML; }
            set { _ShareFolderXML = value; }
        }


        public Config LoadConfig()
        {
        
            XElement elementRoot = XElement.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\DBConfig.xml");
            Config config = (from q in elementRoot.Elements("Config")
                                    select new Config
                                    {
                                        ServerName = q.Element("ServerName").Value,
                                        DBName = q.Element("DBName").Value,
                                        ShareFolderCSV = q.Element("ShareFolderCSV").Value,
                                        ShareFolderXML = q.Element("ShareFolderXML").Value

                                    }).First();
            return config;
        }
      
       
    }
}
